/* eslint-disable */
<template>
	<div class="dataGroup">
		<div class="userCollapse" >
			<el-form class='searchform' :inline="true" :model="form" ref="form" label-width="140px">
				<el-row>
					<el-col :span="24" class="flex flex-vc rowItem">
						<el-button  @click="showcollse=!showcollse" class="showsearchBtn" type="info"
							 :icon="showcollse?'el-icon-caret-top':'el-icon-caret-bottom'"  size="mini" >{{showcollse?$t('common.collseHide'):$t('common.spread')}}</el-button>
						<span class="searchTitle flex-vc inline_flex flex-hc">{{$t('searchEaraLabel.dataGroup')}}</span>
						<div class="userCollapse_item" v-if="showcollse">
							<el-form-item :label="$t('common.dataGroupName')+'：'">
								<el-input v-model="form.dataGroupName" :placeholder="$t('common.inputPlaceholder')"></el-input>
							</el-form-item>
							<el-form-item :label="$t('common.dataGroupCode')+'：'">
								<el-input v-model="form.dataGroupCode" :placeholder="$t('common.inputPlaceholder')"></el-input>
							</el-form-item>
							<el-form-item :label="$t('common.dataGroupType')+'：'">
								<el-select v-model="form.dataGroupType" :placeholder="$t('common.selectPlaceholder')" clearable>
									<el-option v-for="(item,index) in dataGroupTypeDic" :key="index" :label="item.label" :value="item.value"></el-option>
								</el-select>
							</el-form-item>
							<el-form-item :label="$t('common.dataGroupStatus')+'：'">
								<el-select v-model="form.dataGroupStatus" :placeholder="$t('common.selectPlaceholder')" >
									<el-option v-for="(item,index) in statusDic" :key="index" :label="item.label" :value="item.value"></el-option>
								</el-select>
							</el-form-item>
							<el-form-item :label="$t('common.resourceName')+'：'">
								<el-input v-model="form.resourceName" :placeholder="$t('common.inputPlaceholder')"></el-input>
							</el-form-item>
							<el-form-item :label="$t('common.isCustom1')+'：'">
								<el-select v-model="form.isCustom" :placeholder="$t('common.selectPlaceholder')" clearable>
									<el-option v-for="(item,index) in selectSection" :key="index" :label="item.label" :value="item.value"></el-option>
								</el-select>
							</el-form-item>
							<el-form-item :label="$t('common.ownerAccount')+'：'">
								<el-input v-model="form.ownerAccount" :placeholder="$t('common.inputPlaceholder')"></el-input>
							</el-form-item>
						</div>
						<div class="userCollapse_hide" v-if="!showcollse">
							<span>{{$t('common.dataGroupName')}}:</span><strong>【{{form.dataGroupName?form.dataGroupName:$t('common.all')}}】</strong>
							<span>{{$t('common.dataGroupCode')}}:</span><strong>【{{form.dataGroupCode?form.dataGroupCode:$t('common.all')}}】</strong>
							<span>{{$t('common.dataGroupType')}}:</span><strong>【{{getSearchAreaName('dataGroupType')}}】</strong>
							<span>{{$t('common.dataGroupStatus')}}:</span><strong>【{{getSearchAreaName('dataGroupStatus')}}】</strong>
							<span>{{$t('common.resourceName')}}:</span><strong>【{{form.resourceName?form.resourceName:$t('common.all')}}】</strong>
							<span>{{$t('common.isCustom1')}}:</span><strong>【{{getSearchAreaName('isCustom')}}】</strong>
							<span>{{$t('common.resourceName')}}:</span><strong>【{{getSearchAreaName('isCustom')}}】</strong>

						</div>
					</el-col>

				</el-row>
			</el-form>
		</div>
		<!--操作区域-->
		<el-row>
			<el-col :span="18">
				<div class="operateBtn">
					<el-button  @click="addnew" >{{$t('modules.datagroupManage.add')}}</el-button>
					<el-button @click="beforeupdate(1)" >{{$t('modules.datagroupManage.modify')}}</el-button>
					<el-button @click="batchDisabled">{{$t('modules.datagroupManage.statusChoice')}}</el-button>
					<el-button @click="beforeupdate(2)">{{$t('modules.datagroupManage.appendMainData')}}</el-button>
					<el-button @click="beforeupdate(3)">{{$t('modules.datagroupManage.definedVariable')}}</el-button>
				</div>
			</el-col>
			<el-col :span="6">
				<div class="searchBtn">
					<el-button type="primary" @click="onSearch" >{{$t('common.searchBtn')}}</el-button>
					<el-button type="primary" @click="resetSearch" >{{$t('common.resetBtn')}}</el-button>
				</div>
			</el-col>
		</el-row>

		<!--系统信息列表-->
		<el-table class="data-list "  v-loading="loadind" ref="multipleTable" :data="dataList" border @selection-change="selectChange" @row-dblclick="update" highlight-current-row  >
			<el-table-column  type="selection" width="55"></el-table-column>
			<el-table-column v-for="item in tableVisibleArr" :key="item.prop" :prop="item.prop" :label="item.label"  align="center"  show-overflow-tooltip :formatter="formatter"></el-table-column>
		</el-table>
	    <div class="tablebottom" style="position:relative;">
			<el-pagination
		      @size-change="pageSizeChange"
		      @current-change="handleCurrentChangePage"
		      :current-page="pagination.pageNum"
		      :page-sizes="[10,20, 50, 100, 200]"
		      :page-size="pagination.pageSize"
		      layout="->,prev, pager, next, jumper, sizes,total"
		      :total="pagination.totalSize">
		    </el-pagination>
		    <!-- 自定义表格字段组件 -->
		    <defined-table storageName="basp_datagroupManage"  :headArr="headArr" :selectArr="tableVisibleArr" @saveAutoDefinedTable="saveAutoDefinedTable"></defined-table>
		</div>
		<!--新增修改-->
		<el-dialog class="newlyForm" :title="dialogType==1?$t('modules.datagroupManage.addNewDatagroup'):$t('modules.datagroupManage.modifyDatagroup')" :visible.sync="newlyFormVisible"  width="50%" @close="closeDialog" :close-on-click-modal="false">
			<el-row>
			  <el-col :span="22">
			  		<el-form :rules="rules"  :inline="false" :model="dataGroupInfoForm" ref="dataGroupInfoForm" label-width="140px">
						<el-form-item :label="$t('common.resourceName')+'：'" prop="resourceName">
							<el-autocomplete :disabled="dialogType!=1"
								 v-model="dataGroupInfoForm.resourceName"  :placeholder="$t('common.inputPlaceholder')"
						      :fetch-suggestions="$resourceNameSelectOwns"
						      @select="resourceNameSleSelect" :trigger-on-focus="false"
						    ></el-autocomplete >
						</el-form-item>
						<!--<el-form-item label="数据组ID："  >
							<el-input :disabled="true" v-model="dataGroupInfoForm.dataGroupId" placeholder="系统自动生成"></el-input>
						</el-form-item>-->
						<el-form-item :label="$t('common.dataGroupCode')+'：'" prop="dataGroupCode">
							<el-input :disabled="dialogType!=1" v-model="dataGroupInfoForm.dataGroupCode" placeholder="如：88888888+dataGroupDemo"></el-input>
						</el-form-item>
						<el-form-item :label="$t('common.dataGroupName')+'：'" prop="dataGroupName">
							<el-input  :maxlength="128" @change="dataGroupInfoForm.dataGroupName=$checkTextValidate(dataGroupInfoForm.dataGroupName)"  v-model="dataGroupInfoForm.dataGroupName" :placeholder="$t('common.inputPlaceholder')"></el-input>
						</el-form-item>
						<el-form-item :label="$t('common.dataGroupDesc')+'：'" prop="dataGroupDesc">
							<el-input :maxlength="128" @change="dataGroupInfoForm.dataGroupDesc=$checkTextValidate(dataGroupInfoForm.dataGroupDesc)"  type="textarea" :rows="2"  v-model="dataGroupInfoForm.dataGroupDesc" :placeholder="$t('common.inputPlaceholder')"></el-input>
						</el-form-item>
						<el-form-item :label="$t('common.dataGroupType')+'：'" prop="dataGroupType">
							<el-select  :disabled="dialogType!=1" v-model="dataGroupInfoForm.dataGroupType" :placeholder="$t('common.selectPlaceholder')">
								<el-option v-for="(item,index) in dataGroupTypeDic" :key="index" :label="item.label" :value="item.value"></el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="ETL_ID：">
							<el-input :maxlength="128" @change="dataGroupInfoForm.etlDataGroupId=$getTextNumber(dataGroupInfoForm.etlDataGroupId)"  v-model="dataGroupInfoForm.etlDataGroupId" :placeholder="$t('common.inputPlaceholder')"></el-input>
						</el-form-item>
					</el-form>
			  </el-col>
			</el-row>
			<div slot="footer" class="dialog-footer">
				<el-button @click="giveupFun('newlyFormVisible')">{{$t('common.giveUp')}}</el-button>
				<el-button v-loading.fullscreen.lock="fullscreenLoading" type="primary" @click="submitForm">{{$t('common.save')}}</el-button>
			</div>
		</el-dialog>

		<!--定义变量表达式-->
		<el-dialog class="autoDefinedResource" :title="$t('modules.datagroupManage.definedVariable')" :visible.sync="autoDefinedVisible"   width="60%"  :close-on-click-modal="false" @close="closeAutoDefinedDialog">
			<el-form :rules="rules"  :inline="false" :model="dataGroupRow" ref="dataGroupRow"  label-width="100px">
				<el-col :span="12">
					<el-form-item :label="$t('common.resourceName')+'：'" >
						<el-input  readonly v-model="dataGroupRow.resourceName" :placeholder="$t('common.inputPlaceholder')"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item :label="$t('common.dataGroupName')+'：'" label-width="120px">
						<el-input  readonly v-model="dataGroupRow.dataGroupName" :placeholder="$t('common.inputPlaceholder')"></el-input>
					</el-form-item>
				</el-col>
				<el-form-item :label="$t('modules.datagroupManage.params')+'：'" prop="params">
					<el-input :maxlength="128"  type="textarea"  :rows="5"   v-model="dataGroupRow.params" :placeholder="$t('common.inputPlaceholder')"></el-input>
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="giveupFun('autoDefinedVisible')">{{$t('common.giveUp')}}</el-button>
				<el-button type="primary" @click="saveAutoDefined">{{$t('common.save')}}</el-button>
			</div>
		</el-dialog>
		<!--绑定资源主数据-->
		<append-datasource :visible="appendDataResourceVisible" :mainRow="dataGroupRow"  @close="appendDataResourceVisible=false" @saveResourceChecked="saveResourceChecked"></append-datasource>
		<!--绑定资源主数据-->
	</div>
</template>
<script>
import {
    Message, Notification, MessageBox, Loading
} from 'element-ui'
import definedTable from "../components/definedTable"
import appendDatasource from "../components/appendDatasource.vue"
export default {
		name: 'datagroupManage',
    components: {
        definedTable,
        appendDatasource
    },
    data () {
        return {
            autoDefinedVisible: false,
            appendDataResourceVisible: false,
            dataGroupRow: {
                paramStruct: 1
            },
            showcollse: false,
            form: {
                resourceName: '',
                dataGroupCode: '',
                dataGroupName: '',
                dataGroupStatus: 1,
                dataGroupType: '',
                isCustom: '',
                ownerAccount: ''
            },
            dataGroupInfoForm: {
                dataGroupId: '',
                dataGroupCode: '',
                dataGroupName: '',
                dataGroupType: 0,
                dataGroupDesc: '',
                isCustom: 0,
                resourceName: '',
                etlDataGroupId: ''
            },
            rules: {
                dataGroupCode: [
		            { required: true, message: this.$t('validateWornText.inputDataGroupCode'), trigger: 'blur' }
		        ],
		        dataGroupName: [
		            { required: true, message: this.$t('validateWornText.inputDataGroupName'), trigger: 'blur' }
		        ],
                dataGroupDesc: [
		            { required: true, message: this.$t('validateWornText.inoutDataGroupDesc'), trigger: 'blur' }
		        ],
		        dataGroupType: [
		            { required: true, message: this.$t('validateWornText.selectDataGroupType'), trigger: 'change' }
		        ],
		        resourceName: [
		            { required: true, message: this.$t('validateWornText.selectResourceName'), trigger: 'change' }
		        ],
		        params: [
		            { required: true, message: this.$t('validateWornText.inputAutoDefinedVariable'), trigger: 'blur' }
		        ]

            },
            selectSection: [{ value: 0, label: this.$t('common.not') }, { value: 1, label: this.$t('common.is') }],
            resourceNameList: [],
            statusDic: [
                { value: 1, label: (window.sessionStorage.getItem('lang') == 'zh-CN') ? "启用" : 'enabled' },
			    { value: 0, label: (window.sessionStorage.getItem('lang') == 'zh-CN') ? "禁用" : 'disabled' }
            ], // 状态字典
            dataGroupTypeDic: [
                { value: 0, label: this.$t('modules.datagroupManage.constant') }, { value: 1, label: this.$t('modules.datagroupManage.variable') }
            ], // 数据组字典
            pagination: {
                totalSize: 0,
                pageSize: 10,
                pageNum: 1,
                totalPage: 0
            },
            dataList: [],
            loadind: false,
            multipleSelection: [],
            chooseSelectionArr: [],
            newlyFormVisible: false,
            dialogType: 1,
            headArr: [
			    { prop: "ownerSysName", label: this.$t('common.ownerSys'), index: 0 },
			    { prop: "resourceName", label: this.$t('common.resourceName'), index: 1 },
                { prop: "dataGroupId", label: this.$t('common.dataGroupId'), index: 2 },
                { prop: "dataGroupCode", label: this.$t('common.dataGroupCode'), index: 3 },
                { prop: "dataGroupName", label: this.$t('common.dataGroupName'), index: 4 },
                { prop: "dataGroupType", label: this.$t('common.dataGroupType'), index: 5 },
                { prop: "isCustom", label: this.$t('common.isCustom1'), index: 6 },
                { prop: "ownerAccountName", label: this.$t('common.ownerAccount'), index: 7 },
                { prop: "dataGroupStatus", label: this.$t('common.dataGroupStatus'), index: 8 },
                { prop: "lastUpdator", label: this.$t('common.lastUpdator'), index: 9 },
                { prop: "lastUpdateTm", label: this.$t('common.lastUpdateTm'), index: 10 },
                { prop: "creator", label: this.$t('common.creator'), index: 11 },
                { prop: "createTm", label: this.$t('common.createTm'), index: 12 }
            ],
            tableVisibleArr: [],
            fullscreenLoading: false
        }
    },
    mounted () {
    	var pageObj = localStorage.getItem('basp_datagroupManage') // 捞出缓存中的该页面的表格配置
    	if (pageObj) {
    		var obj = JSON.parse(pageObj)
    		if (sessionStorage.getItem('userName')) {
    			this.saveAutoDefinedTable(obj[sessionStorage.getItem('userName')])
    		} else {
    			this.tableVisibleArr = this.$deepCopy(this.headArr, [])
    		}
    	} else {
    		this.tableVisibleArr = this.$deepCopy(this.headArr, [])
    	}
        this.searchHttp()
    },
    methods: {
        saveAutoDefinedTable (arr) { // 配置表格可见的选项
            var temp = []
            for (var i = 0; i < arr.length; i++) {
                temp.push(this.headArr[arr[i]])
            }
            this.tableVisibleArr = temp
        },
        selectChange (val) {
            this.multipleSelection = val
        },
        resourceNameSleSelect (item) {
            this.dataGroupInfoForm.resourceName = item.value.split('/')[1]
            this.dataGroupInfoForm.resourceId = item.id
        },
        searchHttp () {
            var param = {
                resourceName: this.form.resourceName,
                dataGroupCode: this.form.dataGroupCode,
                dataGroupName: this.form.dataGroupName,
                dataGroupStatus: this.form.dataGroupStatus,
                dataGroupType: this.form.dataGroupType,
                isCustom: this.form.isCustom,
                ownerAccount: this.form.ownerAccount,
                pageSize: this.pagination.pageSize,
                pageNum: this.pagination.pageNum
            }
            this.loadind = true
            var that = this
            this.$httpExt().post('/dev-basp-system/dataGroup/queryList', param)
                .then((response) => {
                    this.loadind = false
                    var body = response.result
                    this.pagination.totalSize = body.totalSize
                    this.dataList = body.data
                    var tempSelectCurrent = []
                    if (that.chooseSelectionArr.length > 0) {
                        for (var i = 0; i < that.dataList.length; i++) {
                            for (var k = 0; k < that.chooseSelectionArr.length; k++) {
                                var id1 = that.chooseSelectionArr[k].dataGroupId
                                var id2 = that.dataList[i].dataGroupId
                                if (id1 == id2) {
                                    tempSelectCurrent.push(that.dataList[i])
                                    that.chooseSelectionArr.splice(k, 1)
                                    break
                                }
                            }
                        }
                    }
                    this.$nextTick(() => {
                        that.toggleSelection(tempSelectCurrent, "multipleTable")
                    })
                }, (response) => {
                    this.loadind = false
                    Notification.error({
                        title: this.$t('common.exception'),
                        message: response.msg ? response.msg : this.$t('common.exceptionWornText')
                    })
                })
        },
        toggleSelection (rows, val) {
            if (rows.length) {
	          rows.forEach(row => {
	            this.$refs[val].toggleRowSelection(row)
	          })
	        } else {
	          this.$refs[val].clearSelection()
	        }
	    },
        handleCurrentChangePage (val) {
            this.chooseSelectionArr = this.chooseSelectionArr.concat(this.multipleSelection)
            this.pagination.pageNum = val
            this.searchHttp()
        },
        pageSizeChange (val) {
            this.chooseSelectionArr = this.chooseSelectionArr.concat(this.multipleSelection)
            this.pagination.pageNum = 1
            this.pagination.pageSize = val
            this.searchHttp()
        },
        resetSearch () {
            this.form = {
                resourceName: '',
                dataGroupCode: '',
                dataGroupName: '',
                dataGroupStatus: 1,
                dataGroupType: '',
                isCustom: '',
                ownerAccount: ''
            }// 重置搜索域
        },
        onSearch () {
            this.multipleSelection = []// 清空当前页面勾选项
            this.chooseSelectionArr = []// 清空页面所有勾选项
            this.pagination.pageNum = 1
            this.searchHttp()
        },
        batchDisabled () {
            var text
            var tempAllselectData = this.$deepCopy(this.chooseSelectionArr, [])
            tempAllselectData = tempAllselectData.concat(this.multipleSelection)
            if (tempAllselectData.length > 0) {
                if (tempAllselectData[0].dataGroupStatus == 1) {
                    text = this.$t('modules.datagroupManage.disabledDataTip')
                } else {
                    text = this.$t('modules.datagroupManage.confirmEnableTip')
                }
                this.$confirm(text, this.$t('common.tip'), {
		          	confirmButtonText: this.$t('common.submitOption'),
		          	cancelButtonText: this.$t('common.cancelOption')
		        }).then(() => {
		        	var urlH = '/dev-basp-system/dataGroup/state'
                    let loadingInstance = Loading.service({ fullscreen: true })
                    var param = []
                    for (var i = 0; i < tempAllselectData.length; i++) {
                        param.push({
                            dataGroupId: tempAllselectData[i].dataGroupId,
                            resourceId: tempAllselectData[i].resourceId,
                            status: tempAllselectData[0].dataGroupStatus == 1 ? 0 : 1
                        })
                    }
                    var that = this
                    this.$httpExt().post(urlH, param)
                        .then((response) => {
                            that.onSearch()
                            loadingInstance.close()
                        }, (response) => {
                            loadingInstance.close()
                            Notification.error({
                                title: this.$t('common.exception'),
                                message: response.msg ? response.msg : this.$t('common.exceptionWornText')
                            })
                        })
		        }).catch(() => {
		        })
            } else {
                MessageBox({
                    message: (window.sessionStorage.getItem('lang') == 'zh-CN') ? '请至少选择一条数据进行操作!' : 'Please select at least one data for operation!',
                    confirmButtonText: this.$t('common.iknow')
                })
            }
        },
	    closeDialog () { // 关闭新增，修改模态框
	    	this.newlyFormVisible = false
            this.$refs['dataGroupInfoForm'].resetFields()// 重置表单
            this.dataGroupInfoForm = {
                dataGroupId: '',
                dataGroupCode: '',
                dataGroupName: '',
                dataGroupType: 0,
                dataGroupDesc: '',
                isCustom: 0,
                resourceName: '',
                resourceId: '',
                etlDataGroupId: ''
            }
	    },
	    addnew () { // 新增数据组
	    	this.newlyFormVisible = true
	    	this.dialogType = 1 // 标识新增flag
	    },
	    // 修改
	    update (row) {
	    	this.dialogType = 2
	    	this.dataGroupInfoForm = {
	    		dataGroupId: row.dataGroupId,
                dataGroupCode: row.dataGroupCode,
                dataGroupName: row.dataGroupName,
                dataGroupType: row.dataGroupType,
                dataGroupDesc: row.dataGroupDesc,
                isCustom: row.isCustom ? row.isCustom : 0,
                resourceName: row.resourceName,
                resourceId: row.resourceId,
                etlDataGroupId: row.etlDataGroupId
            }
	    	this.newlyFormVisible = true
	    },
	    giveupFun (val) { // 放弃填写
	    	this.$confirm(this.$t('modules.datagroupManage.giveUpEditWornTip'), this.$t('common.tip'), {
          		confirmButtonText: this.$t('common.submitOption'),
	          	cancelButtonText: this.$t('common.cancelOption')
	        }).then(() => {
	        	this[val] = false
	        }).catch(() => {
	        })
	    },
	    submitForm () {
	    	this.$refs['dataGroupInfoForm'].validate((valid) => {
			    if (valid) {
			    	this.$confirm(this.$t('modules.datagroupManage.confirmSubmitTip'), this.$t('common.tip'), {
			          	confirmButtonText: this.$t('common.submitOption'),
	          			cancelButtonText: this.$t('common.cancelOption')
			        }).then(() => {
                        var urlH = this.dialogType == 1 ? '/dev-basp-system/dataGroup/add' : '/dev-basp-system/dataGroup/update'
                        var param = {
                            dataGroupId: this.dataGroupInfoForm.dataGroupId,
                            dataGroupCode: this.dataGroupInfoForm.dataGroupCode,
                            dataGroupName: this.dataGroupInfoForm.dataGroupName,
                            dataGroupType: this.dataGroupInfoForm.dataGroupType,
                            dataGroupDesc: this.dataGroupInfoForm.dataGroupDesc,
                            isCustom: this.dataGroupInfoForm.isCustom,
                            resourceId: this.dataGroupInfoForm.resourceId,
                            etlDataGroupId: this.dataGroupInfoForm.etlDataGroupId
                        }
                        this.fullscreenLoading = true
                        this.$httpExt().post(urlH, param)
                            .then((response) => {
                                this.fullscreenLoading = false
                                this.$message({
						          message: response.msg ? response.msg : this.$t('modules.datagroupManage.saveSuccess'),
						          type: 'success'
						    })
                                this.newlyFormVisible = false
                                this.onSearch()
                            }, (response) => {
                                this.fullscreenLoading = false
                                Notification.error({
                                    title: this.$t('common.exception'),
                                    message: response.msg ? response.msg : this.$t('common.exceptionWornText')
                                })
                            })
			        }).catch(() => {
			        })
			    } else {
                    return false
                }
            })
	    },
	    // 判断勾选
	    beforeupdate (param) {
	    	if (this.multipleSelection.length == 1) {
                if (param == 1) { // 修改
                    if (this.multipleSelection[0].dataGroupStatus == 0) { // 状态为禁用
                        this.$message({
					          message: this.$t('modules.datagroupManage.modifedtip'),
					          type: 'warning'
					    })
                        return
                    }
                    this.update(this.multipleSelection[0])
                } else if (param == 2) { // 绑定资源主数据
                    if (this.multipleSelection[0].dataGroupStatus == 0) { // 状态为禁用
                        this.$message({
					          message: this.$t('modules.datagroupManage.appendTip'),
					          type: 'warning'
					    })
                        return
                    }
                    if (this.multipleSelection[0].dataGroupType == 1) { // 自定义变量
                        this.$message({
					          message: this.$t('modules.datagroupManage.dataGroupTypeTip'),
					          type: 'warning'
					    })
                        return
                    }
                    this.dataGroupRow.resourceName = this.multipleSelection[0].resourceName
                    this.dataGroupRow.resourceId = this.multipleSelection[0].resourceId
                    this.dataGroupRow.dataGroupName = this.multipleSelection[0].dataGroupName
                    this.dataGroupRow.dataGroupId = this.multipleSelection[0].dataGroupId
                    this.dataGroupRow.paramStruct = this.multipleSelection[0].paramStruct
		    this.dataGroupRow.paramUrl = this.multipleSelection[0].paramUrl
		    this.dataGroupRow.paramType = this.multipleSelection[0].paramType
                    this.bandToMainSource()
                } else { // 定义变量表达式
                    if (this.multipleSelection[0].dataGroupStatus == 0) { // 状态为禁用
                        this.$message({
					          message: this.$t('modules.datagroupManage.dataGroupStatusTip'),
					          type: 'warning'
					    })
                        return
                    }
                    if (this.multipleSelection[0].dataGroupType == 0) { // 自定义变量
                        this.$message({
					          message: this.$t('modules.datagroupManage.currentTypeTip'),
					          type: 'warning'
					    })
                        return
                    }
                    this.dataGroupRow = {
                        resourceId: this.multipleSelection[0].resourceId,
                        dataGroupId: this.multipleSelection[0].dataGroupId,
                        resourceName: this.multipleSelection[0].resourceName,
                        dataGroupName: this.multipleSelection[0].dataGroupName,
			paramUrl:this.multipleSelection[0].paramUrl,
                        params: this.multipleSelection[0].params
                    }
                    this.customDifined()
                }
            } else {
                MessageBox({
                    message: (window.sessionStorage.getItem('lang') == 'zh-CN') ? '请至少选择一条数据进行操作!' : 'Please select at least one data for operation!',
                    confirmButtonText: this.$t('common.iknow')
                })
            }
	    },
	    bandToMainSource () { // 打开绑定资源弹窗
	    	this.appendDataResourceVisible = true
	    },
	    saveResourceChecked (currentCheckedNodes) {
	    	var codeList = []
    		for (var i = 0; i < currentCheckedNodes.length; i++) {
    			codeList.push(currentCheckedNodes[i].code)
    		}
    		var param = {
                dataGroupId: this.dataGroupRow.dataGroupId,
                resourceId: this.dataGroupRow.resourceId,
                codeList: codeList,
		paramUrl:this.dataGroupRow.paramUrl
            }
	    	var urlH = "/dev-basp-system/dataGroup/saveParams"
            let loadingInstance = Loading.service({ fullscreen: true })
            this.$httpExt().post(urlH, param)
                .then((response) => {
                    loadingInstance.close()
                    this.$message({
			          message: response.msg ? response.msg : this.$t('modules.datagroupManage.appendDataSuccess'),
			          type: 'success'
			    })
			    this.appendDataResourceVisible = false
                }, (response) => {
                    loadingInstance.close()
                    Notification.error({
                        title: this.$t('common.exception'),
                        message: response.msg ? response.msg : this.$t('common.exceptionWornText')
                    })
                })
	    },
	    customDifined () {
	    	this.autoDefinedVisible = true
	    	this.searchCustomDifined()// 搜索自定义的变量表达式
	    },
	    closeAutoDefinedDialog () { // 关闭自定义变量弹框
	    	this.$refs['dataGroupRow'].resetFields()// 重置表单
	    	this.pagination.pageNum = 1
	    },
	    searchCustomDifined () {
	    	var urlH = '/dev-basp-system/dataGroup/selectParemsVariable'
            var param = {
                dataGroupId: this.dataGroupRow.dataGroupId,
                resourceId: this.dataGroupRow.resourceId
            }
            this.$httpExt().post(urlH, param)
                .then((response) => {
                    this.dataGroupRow.params = response.result.params
                }, (response) => {
                    Notification.error({
                        title: this.$t('common.exception'),
                        message: response.msg ? response.msg : this.$t('common.exceptionWornText')
                    })
                })
	    },
	    saveAutoDefined () { // 自定义变量表达式
	    	this.$refs['dataGroupRow'].validate((valid) => {
			    if (valid) {
			    	var urlH = '/dev-basp-system/dataGroup/saveParams'
                    var param = {
                        dataGroupId: this.dataGroupRow.dataGroupId,
                        resourceId: this.dataGroupRow.resourceId,
                        codeList: [this.dataGroupRow.params],
			paramUrl:this.dataGroupRow.paramUrl
                    }
                    this.$httpExt().post(urlH, param)
                        .then((response) => {
                            this.$message({
					          message: response.msg ? response.msg : this.$t('modules.datagroupManage.saveSuccess'),
					          type: 'success'
					    })
                            this.autoDefinedVisible = false
                            this.pagination.pageNum = 1
                            this.onSearch()
                        }, (response) => {
                            Notification.error({
                                title: this.$t('common.exception'),
                                message: response.msg ? response.msg : this.$t('common.exceptionWornText')
                            })
                        })
			    } else {
                    return false
                }
            })
	    },
	     getSearchAreaName (val) {
		   	switch (val) {
		   		case "dataGroupType":
                for (var a = 0; a < this.dataGroupTypeDic.length; a++) {
                    if (this.form.dataGroupType === this.dataGroupTypeDic[a].code) {
                        return this.dataGroupTypeDic[a].label
                    }
                }
                return this.$t('common.all')
            case "dataGroupStatus":
                for (var c = 0; c < this.statusDic.length; c++) {
                    if (this.form.dataGroupStatus === this.statusDic[c].value) {
                        return this.statusDic[c].label
                    }
                }
                return this.$t('common.all')
            case "isCustom":
                for (var e = 0; e < this.selectSection.length; e++) {
                    if (this.form.isCustom === this.selectSection[e].value) {
                        return this.selectSection[e].label
                    }
                }
                return this.$t('common.all')
            default : return this.form[val]; 
		   	}
	    },
	    formatter (row, column) { // 状态信息中表格展开项的code转为name
            switch (column.property) {
            case "dataGroupStatus":// 授权状态
                for (var i = 0; i < this.statusDic.length; i++) {
                    if (row.dataGroupStatus == this.statusDic[i].value) {
                        return this.statusDic[i].label
                    }
                }
                return row.dataGroupStatus
            case "dataGroupType":// 数据组类型
                for (var b = 0; b < this.dataGroupTypeDic.length; b++) {
                    if (row.dataGroupType == this.dataGroupTypeDic[b].value) {
                        return this.dataGroupTypeDic[b].label
                    }
                }
                return row.dataGroupType
            case "isCustom":// 是否用户自定义
                for (var a = 0; a < this.selectSection.length; a++) {
                    if (row.isCustom == this.selectSection[a].value) {
                        return this.selectSection[a].label
                    }
                }
                return row.isCustom
            case "lastUpdateTm":return this.$format(row.lastUpdateTm, "yyyy/MM/dd hh:mm:ss");  // 修改时间
            case "createTm":return this.$format(row.createTm, "yyyy/MM/dd hh:mm:ss");  // 创建时间
            default : return row[column.property]; 
            }
	    }

    }
}
</script>
<style lang="less">
@import "../common/css/common.less";
.dataGroup{
	.el-collapse-item__header{
		font-weight: bold;
	}
	.searchTitle.el-form-item__label{
		width:90px;
	}
}
</style>
